// 动态规划

class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        int m = INT_MIN, pre = 0;
        for (auto& num: nums) {
            pre = max(num, pre + num);
            m = max(m, pre);
        }
        return m;
    }
};